/*
 *  CEModalView.h
 *  LID Library
 *
 *  Created by Alexander Trutchenko on 09/11/11.
 *  Copyright 2011 League of Independent Developers. All rights reserved.
 *
 */

#ifndef __CE_ModalView_h__
#define __CE_ModalView_h__

#include "cocos2dx_extentions/nodes/CENodeRGBA.h"
#include "cocos2d.h"

namespace cocosext {

#define CE_MODAL_VIEW_FADE_TIME 0.5f
#define CE_MODAL_VIEW_TOUCH_PRIORITY -1000

#define kCEOnModalViewStartOpen		"kCEOnModalViewStartOpen"
#define kCEOnModalViewFinishOpen	"kCEOnModalViewFinishOpen"
#define kCEOnModalViewStartClose	"kCEOnModalViewStartClose"
#define kCEOnModalViewFinishClose	"kCEOnModalViewFinishClose"

/////////////////////////////////////////////////////
//
/** CEModalView 
* ModalView is a full screen modal wnd Layer that has a high (CE_MODAL_VIEW_TOUCH_PRIORITY) touch priority.
* When it starts, it sends kCEOnModalViewStartOpen notification  (this is a parameter)
* When it stops, it sends kCEOnModalViewFinishClose notification  (this is a parameter)
*/
/////////////////////////////////////////////////////

class CEModalView : public cocos2d::CCLayerColor
{
	bool _sendNotifications;
	bool _autoShowHide;
	GLubyte _resultAlpha;

	bool _isResizeBlocked;
	bool _isChildContainsBeginTouch;
	bool _isTouchProcessingBlocked;


protected:


protected:
	CEModalView(bool sendNotifications, bool autoShowHide)
		: _sendNotifications(sendNotifications)
		, _autoShowHide(autoShowHide)
		, _resultAlpha(0)
	    , _isResizeBlocked(false)
		, _isChildContainsBeginTouch(false)
		, _isTouchProcessingBlocked(true)  {;}

public:
	virtual ~CEModalView() {;}

//	static bool createAndAttachToCurrentScene(const cocos2d::ccColor4B& color);

protected:
	virtual bool init(const cocos2d::ccColor4B& color);

public:
// Main interface

//Cocos2d interface
	virtual void setRotation(float fRotation);
	virtual void setContentSize(const cocos2d::CCSize& contentSize);
	virtual void registerWithTouchDispatcher();

// Touch processing
	virtual bool ccTouchBegan(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent);
    virtual void ccTouchMoved(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent);
    virtual void ccTouchEnded(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent);
    virtual void ccTouchCancelled(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent);

protected:

	virtual void open();
	virtual void finishOpen();

	virtual void close();
	virtual void finishClose();
};


}; // end namespace cocosext

#endif // __CE_ModalView_h__
